
export default {
  data() {
    return {
      disabled: false,
      text: this.$t(`page.store.getCode`)
    };
  },
  methods: {
    sendCode() {
      if (this.disabled) return;
      this.disabled = true;
      let n = 60;
      this.text = `${this.$t(`page.store.remaining`)} ${n} s`;
      const run = setInterval(() => {
        n = n - 1;
        this.text = `${this.$t(`page.store.remaining`)} ${n} s`;

        if (n < 0) {
          clearInterval(run);
          this.disabled = false;
          this.text = this.$t(`page.store.resendCode`);
        }
      }, 1000);
    }
  }
};
